class  OuterClass {
    public int data1 = 1;
    public int data2 = 2;
    public static int data3 = 3;

    static class InnerClass{
        //静态内部类
        public int data4 = 4;
        public int data5 = 5;
        public static int data6 = 6;

        public void testInner(){
            System.out.println("InnerClass::testInner()...........");
            OuterClass outerClass1 = new OuterClass();
            System.out.println(outerClass1.data1);
            System.out.println(outerClass1.data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data3);
        }
    }


    public void test() {
        System.out.println("OuterClass::test()............");
    }
}


class OuterClass2 {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    class InnerClass {
        public int data1 = 99999;

        public int data4 = 4;
        public int data5 = 5;
        public static int data6 = 6;

        public void test() {
            //通过给一个外部类对象
            OuterClass outerClass = new OuterClass();
            System.out.println(outerClass.data1);
            //通过外部类类名.this
            System.out.println(OuterClass2.this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }
}
    //定义一个接口
interface Greeting{
        void greet();
}

public class Test {
    public static void main(String[] args) {
        Greeting greeting = new Greeting(){
            @Override
            public void greet() {
                System.out.println("haha");
            }
        };
        greeting.greet();
    }
    public static void main2(String[] args) {
        OuterClass2 outerClass2 = new OuterClass2();
        OuterClass2.InnerClass innerClass2 =  outerClass2.new InnerClass();

        OuterClass2.InnerClass innerClass = new OuterClass2().new InnerClass();

        innerClass2.test();
    }
    public static void main1(String[] args) {
        OuterClass.InnerClass innerClass = new OuterClass.InnerClass();
        innerClass.testInner();
    }
}
